package com.example.tamplate.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@ApiModel(value = "分类")
public class Category {
        @TableId(type = IdType.AUTO)
        @ApiModelProperty("ID")
        private Integer id;

        @NotBlank(message = "名称不能为空")
        @ApiModelProperty(value = "名称")
        private String name;

//        @NotBlank(message = "图片地址不能为空")
        @ApiModelProperty(value = "图片地址")
        private String img;

        @ApiModelProperty(value = "创建时间")
        private String createtime;

        @ApiModelProperty(value = "状态0隐藏1正常")
        private Integer status;

        // 构造函数，用于初始化创建时间
        public Category() {
                this.createtime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
}

